home *** CD-ROM | disk | FTP | other *** search
- // Written by Carl Lindberg Copyright (c) 1994 by Carl Lindberg.
- // Version 1.0. All rights reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This program is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- #import "mscarl.h"
-
- char *names[12] = {
- "MISC_UPPER",
- "MISC_LOWER",
- "MISC_DIGIT",
- "MISC_XDIGIT",
- "MISC_PUNCT",
- "MISC_ASCII",
- "MISC_CNTRL",
- "MISC_PRINT",
- "MISC_SPACE",
- "MISC_GRAPH",
- "MISC_ALPHA",
- "MISC_ALNUM"
- };
-
- int values[12] = {1,2,4,8,16,32,64,128,256,512,3,7};
-
- #define NUMSTRS 2
-
- char *strs[NUMSTRS] = { "Hello my dear [] 345 How ''are78 we?",
- "OH! DARLING"
- };
-
-
- void main()
- {
- int i,j,k,l;
- id str = [MiscString new];
-
- for (i=0;i<NUMSTRS;i++) {
- printf("------------------------------------------------\n");
- printf("String is: <%s>\n",strs[i]);
- [str setStringValue:strs[i]];
- for (j=0;j<12;j++) {
- printf("Is all %s? %d\n",names[j],[str isAllOfType:values[j]]);
- printf("Has %s? %d\n",names[j],[str hasType:values[j]]);
- printf("Num of %s: %d\n",names[j],[str numOfType:values[j]]);
- printf("spotsof %s: ",names[j]);
- for (k=0;(l=[str spotOfType:values[j] occurrenceNum:k])>=0;k++) printf("%d ",l);
- printf("\n");
- printf("rspotsof %s: ",names[j]);
- for (k=0;(l=[str rspotOfType:values[j] occurrenceNum:k])>=0;k++) printf("%d ",l);
- printf("\n");
- for (k=-1;k<5;k++) printf("replace %dth %s with '*': <%s>\n",k,names[j],
- [[[str copy] replaceType:values[j] withChar:'*' occurrenceNum:k] stringValueAndFree]);
- printf("replaceAll %s with '*': <%s>\n",names[j],[[[str copy] replaceEveryOccurrenceOfType:values[j] withChar:'*'] stringValueAndFree]);
- }
- }
- [str free];
- }
-